package fun.stgoder.bmwf.test1.controller;

import fun.stgoder.bmwf.core.domain.R;
import fun.stgoder.bmwf.test1.domain.Test1;
import fun.stgoder.bmwf.test1.message.MqMessageProducer;
import fun.stgoder.bmwf.test1.service.Test1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test1")
public class Test1Controller {
    @Autowired
    Test1Service test1Service;

    @Autowired
    MqMessageProducer messageProducer;

    @GetMapping("/f1")
    R<List<Test1>> f1(@RequestParam(value = "p", required = false) String p) {
        List<Test1> list = test1Service.f1(p);
        return R.ok(list);
    }

    @GetMapping("/f2")
    R<String> f2() {
        String msg = "msg-" + System.currentTimeMillis();
        messageProducer.sendMsg(msg);
        return R.ok();
    }
}
